using System;
using System.Collections;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using WHC.Pager.Entity;
using WHC.OrderWater.Commons;
using Microsoft.Practices.EnterpriseLibrary.Data;
using WHC.Hotel.Entity;
using WHC.Hotel.IDAL;

namespace WHC.Hotel.DAL
{
	/// <summary>
	/// DiscountInfo 的摘要说明。
	/// </summary>
	public class DiscountInfo : BaseDAL<DiscountInfoInfo>, IDiscountInfo
	{
		#region 对象实例及构造函数

		public static DiscountInfo Instance
		{
			get
			{
				return new DiscountInfo();
			}
		}
		public DiscountInfo() : base("KF_DiscountInfo","Id")
		{
		}

		#endregion

		/// <summary>
		/// 将DataReader的属性值转化为实体类的属性值，返回实体类
		/// </summary>
		/// <param name="dr">有效的DataReader对象</param>
		/// <returns>实体类对象</returns>
		protected override DiscountInfoInfo DataReaderToEntity(IDataReader dataReader)
		{
			DiscountInfoInfo info = new DiscountInfoInfo();
			SmartDataReader reader = new SmartDataReader(dataReader);
			
			info.Id = reader.GetInt32("Id");
			info.CustomerType = reader.GetString("CustomerType");
			info.UnitName = reader.GetString("UnitName");
			info.RoomType = reader.GetString("RoomType");
			info.RoomTypeId = reader.GetInt32("RoomTypeId");
			info.RoomPrice = reader.GetDecimal("RoomPrice");
			info.RoomDiscountPrice = reader.GetDecimal("RoomDiscountPrice");
			info.DiscountPercent = reader.GetDecimal("DiscountPercent");
			info.RelativeId = reader.GetInt32("RelativeId");
			
			return info;
		}

		/// <summary>
		/// 将实体对象的属性值转化为Hashtable对应的键值
		/// </summary>
		/// <param name="obj">有效的实体对象</param>
		/// <returns>包含键值映射的Hashtable</returns>
        protected override Hashtable GetHashByEntity(DiscountInfoInfo obj)
		{
		    DiscountInfoInfo info = obj as DiscountInfoInfo;
			Hashtable hash = new Hashtable(); 
			
 			hash.Add("CustomerType", info.CustomerType);
 			hash.Add("UnitName", info.UnitName);
 			hash.Add("RoomType", info.RoomType);
 			hash.Add("RoomTypeId", info.RoomTypeId);
 			hash.Add("RoomPrice", info.RoomPrice);
 			hash.Add("RoomDiscountPrice", info.RoomDiscountPrice);
 			hash.Add("DiscountPercent", info.DiscountPercent);
 			hash.Add("RelativeId", info.RelativeId);
 				
			return hash;
		}

    }
}